package com.util;

import com.spider.Rule;
import com.spider.RuleException;

/**
 * 检验传入的rule
 *
 * @author Conceit
 * @version 1.0, 2017/1/11
 */
public class ValidateRule {
    public void validataRule(Rule rule) {
        String url = rule.getUrl();
        if (CheckStringIsNull.checkStringIsNull(url)) {
            throw new RuleException("url不能为空！");
        }
        if (!url.startsWith("http://")||url.startsWith("https://")) {
            throw new RuleException("url的格式不正确！");
        }
        if (rule.getParams() != null && rule.getValues() != null) {
            if (rule.getValues().length != rule.getValues().length) {
                throw new RuleException("参数的键值对个数不匹配！");
            }
        }


    }
}
